<?php

namespace backend\modules\pooai\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "zpooai_artical".
 *
 * @property string $zpooai_artical_id
 * @property string $zpooai_pages_id
 * @property string $title
 * @property string $content
 */
class ZpooaiArtical extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'zpooai_artical';
    }

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
//            TimestampBehavior::className(),
            // 名为myBehavior4的行为，也是给出了MyBehavior类的配置数组
            'uuid' => [
                'class' => \common\behavior\uuidBehavior::className(),
                'owner' => $this
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['zpooai_artical_id','default','value'=>$this->getUUID()],
            [['zpooai_artical_id', 'zpooai_pages_id'], 'required'],
            [['content'], 'string'],
            [['zpooai_artical_id', 'zpooai_pages_id'], 'string', 'max' => 40],
            [['title'], 'string', 'max' => 60],
            [['zpooai_pages_id'], 'exist', 'skipOnError' => true, 'targetClass' => ZpooaiPages::className(), 'targetAttribute' => ['zpooai_pages_id' => 'pooai_pages_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'zpooai_artical_id' => Yii::t('app', 'Zpooai Artical ID'),
            'zpooai_pages_id' => Yii::t('app', 'Zpooai Pages ID'),
            'title' => Yii::t('app', 'Title'),
            'content' => Yii::t('app', 'Content'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getZpooaiPages()
    {
        return $this->hasOne(ZpooaiPages::className(), ['pooai_pages_id' => 'zpooai_pages_id']);
    }

    /**
     * @inheritdoc
     * @return ZpooaiArticalQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \backend\modules\pooai\models\query\ZpooaiArticalQuery(get_called_class());
    }
}
